#ifndef DATABASE_H
#define DATABASE_H

#include <QObject>
#include <QDebug>
#include <QStringList>
#include <QDir>
#include <QDeclarativeContext>
#include <QSqlRecord>
#include <QSqlError>
#include <QDateTime>
#include <QTextStream>
#include "sqlquerymodel.h"
#include "expense.h"

class database : public QObject
{
    Q_OBJECT
public:
    explicit database(QObject *parent = 0, QDeclarativeContext *rootCtxt = 0);
    SqlQueryModel expenseM;
    SqlQueryModel accountM;
    QStringList names;
    QString dirName;
    QDir tripDir;
    QStringList tripsList;
    QSqlDatabase db;// = QSqlDatabase::addDatabase("QSQLITE");
    QDeclarativeContext *ctxt;
    Expense *exp;
    
private:
    void getFileList(QStringList *files);
    bool loadTrip();

signals:
    
public slots:
    bool openTrip(const QString dbName);
    bool newTrip(const QString dbName);
    bool editAccount(const QString id, const QString name, const QString parties);
    bool addAccount(const QString id, const QString name, const QString parties);
    bool getExpense(int id);
    bool newExpense();//int id);
    bool editExpense(bool edit, int expns_id);
    QStringList calcShares(int expns_id);
    QString genSummary();
    bool saveSummary(QString trip);
    bool saveReport(QString trip);
    bool exportCSV(QString trip);
    
};

#endif // DATABASE_H
